package edu.sctu.demo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * Created by admin on 2018/6/14.
 */
public class EditDateBase {
    private String id;
    private String username;
    private String password;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void upData() throws Exception {
        Connection connection = null;
        Statement statement = null;

        Class.forName("com.mysql.jdbc.Driver");

        connection = DriverManager.getConnection("jdbc:mysql://localhost:" +
                "3306/sctu_javaweb_2018?serverTimezone = " +
                "UTC&&characterEncoding = UTF-8", "root", "123456");

        statement = connection.createStatement();

        statement.executeUpdate("update t_users SET username = '" + username + "'," +
                " password='" + password + "' WHERE  id = " + id);
        connection.close();
        statement.close();


    }
}
